#pragma once
#include <string>
#include "DefineCol.h"
#include "Global.h"
using namespace std;
class CSymbolInfo;
class CMainFrame;
class CSymbolManager;
class CAccountManager;
class COrderManager;
class CAccountInfo;
class CEventManager
{
public:
	CEventManager();
	~CEventManager();
	int TickNum() const { return m_TickNum; }
	void TickNum(int val) { m_TickNum = val; }
	void InitTickList();
	void AddTickRequest(ChartParam& a_Param);
	ChartTickList m_TickList;

	HogaTickVec m_HogaTickList;

	dqParam   m_ChartRQParam;

	CSymbolManager* m_SymbolMgr;
	CAccountManager* m_AccountMgr;
	COrderManager* m_OrderManager;

	HMODULE		hIns;

	long OnSvrRealChartTick(WPARAM wParam, LPARAM lParam);
	long OnSvrChartData(WPARAM wParam, LPARAM lParam);
	long OnSvrSise(WPARAM wParam, LPARAM lParam);
	long OnSvrHoga(WPARAM wParam, LPARAM lParam);
	long OnSvrJumun(WPARAM wParam, LPARAM lParam);
	long OnSvrJango(WPARAM wParam, LPARAM lParam);
	long OnSvrAccountJango(WPARAM wParam, LPARAM lParam);
	long OnSvrRealJumun(WPARAM wParam, LPARAM lParam);
	long OnSvrRealSise(WPARAM wParam, LPARAM lParam);
	long OnSvrRealHoga(WPARAM wParam, LPARAM lParam);
	long OnSvrRealTick(WPARAM wParam, LPARAM lParam);
	long OnTradeState(WPARAM wParam, LPARAM lParam);

	void RequestCurrentHoga(CSymbolInfo* a_CurSymbol);
	void RequestJangoState(CAccountInfo* a_CurAccount);
	void RequestCurPrice(CSymbolInfo* a_CurSymbol);
	void RequestFilledOrders(CAccountInfo* a_Acc);

	void RequestChartData(ChartParam& a_Param);

	void BroadcastPrice(CSymbolInfo* a_pSymbol);
	void BroadcastQuote(CSymbolInfo* a_pSymbol);
	void BroadcastTick(CSymbolInfo* a_pSymbol);

	void BroadcastRTPrice(CSymbolInfo* a_pSymbol);
	void BroadcastRTQuote(CSymbolInfo* a_pSymbol);
	void BroadcastRTTick(CSymbolInfo* a_pSymbol);

	string GetFullCode(string a_ShortCode);

	void AddChartDataRequest(ChartParam& a_Param);
	void ExecuteChartDataRequest();
	void OnCompleteChartDataRequest();
	void AddHogaTick();
	void UpdateRealTimeHogaTick(CSymbolInfo* a_Sym);

	CMainFrame* m_pMainWnd;

	void SetPrice(ChartTick& a_Price);

	void NewOrder(OrderReqParam& a_ReqParam);

private:
	int  m_TickNum;
	int  m_HogaTickNum;
};

